/*
 * Copyright 2021 <copyright holder> <email>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "mappoint.h"

Mappoint::Mappoint(long id, Vec3 position): id_(id), pos_(position){}

Mappoint::Ptr Mappoint::CreateNewMappoint()
{
    static long factory_id=0;
    Mappoint::Ptr new_mappoint(new Mappoint);
    new_mappoint->id_=factory_id++;
    return new_mappoint;
}

void Mappoint::RemoveObservation(std::shared_ptr<Feature> feat)
{
    std::unique_lock<std::mutex> lck(data_mutex_);
    for(auto iter=observations_.begin(); iter!=observations_.end(); iter++){
    if(iter->lock()==feat){
        observations_.erase(iter);
        //feat->map_point_.;
        observed_times_--;
        break;
        
        }
    }
}

